<?php namespace Phpcmf\Controllers;

/**
 * 二次开发时可以修改本文件，不影响升级覆盖
 */

class Shoucang extends \Phpcmf\Home\Module
{

	public function  shoucang_panduan() {
		//get 参数
		if(!$this->uid){
			$id = (int)\Phpcmf\Service::L('input')->get('id'); //帖子id
		
			$shoucang_tongji = \Phpcmf\Service::M()->db->table('1_zhishi_form_kecheng_shoucang')->where('tieid', $id)->countAllResults();
			$data = [
				'code' => 0,
				'data' => $shoucang_tongji,
				'uid'=> 0,

			];
			$this->_json('1', '未登录',$data);									
		} else {
			$id = (int)\Phpcmf\Service::L('input')->get('id'); //帖子id
		
			$shoucang_data = \Phpcmf\Service::M()->db->table('1_zhishi_form_kecheng_shoucang')->where('tieid', $id)->where('uid', $this->uid)->countAllResults();
			$shoucang_tongji = \Phpcmf\Service::M()->db->table('1_zhishi_form_kecheng_shoucang')->where('tieid', $id)->countAllResults();
			if($shoucang_data){
				$data = [
					'code' => 1,
					'data' => $shoucang_tongji,
					'uid'=> $this->uid,
	
				];
	
				$this->_json('1', '已收藏',$data);
			} else {
				$data = [
					'code' => 2,
					'data' => $shoucang_tongji,
					'uid'=> $this->uid,
	
				];

				$this->_json('0', '未收藏',$data);
			}
		}
		
		
	}

}
